package com.study.system.service;

import com.study.system.entity.Finance;
import com.study.system.mapper.FinanceMapper;
import jakarta.annotation.Resource;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class FinanceService {

    @Resource
    private FinanceMapper financeMapper;

    /**
     * 获取社团财务信息
     *
     * @param clubId 社团ID
     * @return 财务信息列表
     */
    public List<Finance> getFinanceInfo(Integer clubId) {
        return financeMapper.selectFinanceInfoByClubId(clubId);
    }

    public Boolean addFinanceInfo(Integer userId, Finance finance) {
        return financeMapper.addFinanceInfo(userId, finance) == 1;
    }

    public Boolean deleteFinanceInfo(Integer financeId) {
        return financeMapper.deleteFinanceInfo(financeId) == 1;
    }

    public Boolean updateFinanceInfo(Finance finance) {
        return financeMapper.updateFinanceInfo(finance.getType(), finance.getAmount(), finance.getReason(), finance.getTime(), finance.getId()) == 1;
    }

    public List<Finance> searchFinanceInfoByTime(Finance finance) {
        return financeMapper.searchFinanceInfoByTime(finance.getClubId(), finance.getTime());
    }
}
